package com.example.mobile2021606159yhf0508;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import java.util.List;

public class ViewPageAdapter extends FragmentStateAdapter {
    @NonNull
    private final FragmentManager fragmentManager;
    List<Fragment> fragmentList;

    public ViewPageAdapter(@NonNull  FragmentManager fragmentManager,
                           @NonNull  Lifecycle lifecycle,
                           List<Fragment> fragmentList) {
        super((FragmentManager) fragmentList,lifecycle);
        this.fragmentManager = fragmentManager;
        this.fragmentList = fragmentList;
    }

    @NonNull
    @org.jetbrains.annotations.NotNull

    @Override
    public Fragment createFragment(int position){
        return fragmentList.get(position);
    }
    @Override
    public int getItemCount(){
        return fragmentList.size();
    }

}
